﻿using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Net;
using System.Web;

namespace WebMsg
{
    public class MyNetFone : WebMsg
    {
        public MyNetFone()
            : base()
        {
            this.messageURL = @"https://www.mynetfone.com.au/send-sms?";
            this.CustomFrom = false;
        }

        protected override String SendMessage(Sms message)
        {
            String strPost = this.Build(message);
            strPost = HttpUtility.UrlPathEncode(strPost);
            Uri address = new Uri(messageURL + strPost);

            return SendMessage(message, address);
        }

        // Builds the message
        protected String Build(Sms message)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            StringBuilder strPost = new StringBuilder();
            strPost.Append("username=");
            strPost.Append(User);
            strPost.Append("&password=");
            strPost.Append(Pass);
            strPost.Append("&to=");
            strPost.Append(message.To.Number);
            strPost.Append("&text=");
            strPost.Append(message.Body);
            return strPost.ToString();
        }

        protected override void AddResults()
        {
        }

        protected override ResultCodes ParseResult(String raw)
        {
            return base.ParseResult(raw);
        }

        public override String GetCreditsRemaining()
        {
            return "Not Supported";
        }
    }
}
